﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Script.Serialization;

namespace Common
{
    public static class JsonHelper
    {
        // Fields
        private static readonly JavaScriptSerializer Serializer = new JavaScriptSerializer();

        // Methods
        public static string ToJson<T>(this T t)
        {
            return Serializer.Serialize(t);
        }

        public static T ToObject<T>(this string json)
        {
            return Serializer.Deserialize<T>(json);
        }
    }

 

}
